package com.util;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
public class IPTimeStamp {
	
	
	private SimpleDateFormat sdf = null;
	private String ip = null;
	
	public IPTimeStamp(String ip){
		this.ip = ip;
	}
	
	public String getIPTimeRand(){
		StringBuffer buf = new StringBuffer();
		if(this.ip != null){
			String[] s = this.ip.split("\\.");
			for (int i = 0; i < s.length; i++) {// 192,168,0
				buf.append(this.addZero(s[i]));//192168000002

			}
		}
		buf.append(this.getDate());
		
		Random rm = new Random();
		for (int i = 0; i < 3; i++) {
			buf.append(rm.nextInt(10));// 0-9随机数字
		}
		System.out.println(buf.toString());
		return buf.toString();
	}
	public String addZero(String str){
		StringBuffer s = new StringBuffer();
		s.append(str);
		while(s.length()<3){
			s.insert(0, "0");//002
		}
		return s.toString();
	}
	public String getDate(){
		this.sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
		return this.sdf.format(new Date());
	}
}